#ifndef _HTTPSERVERRESPONSEIMPL_HPP_
#define _HTTPSERVERRESPONSEIMPL_HPP_

#include "jhdefs.hpp"
#include "net/HTTPServerResponse.hpp"
#include "net/HTTPServerSession.hpp"

#include <string>
#include <ostream>

NET_NAMESPACE_BEGIN

class CHTTPServerRequestImpl;

class CHTTPServerResponseImpl : public CHTTPServerResponse
{
public:
	CHTTPServerResponseImpl(CHTTPServerSession& session);
	~CHTTPServerResponseImpl();

	void sendContinue();
	std::ostream& send();
	void sendFile(const std::string& path, const std::string& mediaType);
	void sendBuffer(const void* pBuffer, std::size_t length);
	void redirect(const std::string& uri, HTTPStatus status = HTTP_FOUND);
	void requireAuthentication(const std::string& realm);
	bool sent() const;

protected:
	void attachRequest(CHTTPServerRequestImpl* pRequest);

private:
	CHTTPServerSession&		m_session;
	CHTTPServerRequestImpl*	m_pRequest;
	std::ostream*			m_pStream;

	friend class CHTTPServerRequestImpl;
};


NET_NAMESPACE_END

#endif
